package lxh.com.union.logic_business.present;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.HttpParams;
import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.base.Request;

import java.lang.reflect.Type;

import lxh.com.union.config.SinlliaConfig;
import lxh.com.union.frame.mvp.BasePresent;
import lxh.com.union.logic_business.model.bean.BaseBean;
import lxh.com.union.logic_business.model.bean.LoginBean;
import lxh.com.union.logic_business.model.net.INetCallBack;
import lxh.com.union.logic_business.model.net.MyCallBack;
import lxh.com.union.logic_business.model.net.UrlConstant;
import lxh.com.union.logic_business.ui.mvpview.ILoginView;
import lxh.com.union.logic_business.util.LogUtils;
import lxh.com.union.logic_business.util.SharePrefUtils;
import lxh.com.union.logic_business.util.ToastUtils;

/**
 * Created by Administrator on 2017/12/4.
 */

public class LoginPresent extends BasePresent<ILoginView> {

    public void login(String userName, String pwd) {
        OkGo.<String>post(UrlConstant.LOGIN_URL)
                .params("username", userName)
                .params("password", pwd)
                .tag(this)
                .execute(new MyCallBack(LoginBean.class,new INetCallBack() {
                    @Override
                    public void success(Object o) {
                        getView().login((LoginBean) o);
                    }

                    @Override
                    public void failed(Object o) {
                        ToastUtils.showLong(o.toString());
                    }
                }));

    }
}
